package com.ruoyi.personnel.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.personnel.domain.OutwardTraining;
import com.ruoyi.personnel.mapper.OutwardTrainingMapper;
import com.ruoyi.personnel.service.IOutwardTrainingService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 护理部外出培训记录Service业务层处理
 *
 * @author ruoyi
 * @date 2021-02-27
 */
@Service
public class OutwardTrainingServiceImpl extends ServiceImpl<OutwardTrainingMapper, OutwardTraining> implements IOutwardTrainingService {

    @Override
    public List<OutwardTraining> queryList(OutwardTraining outwardTraining) {
        LambdaQueryWrapper<OutwardTraining> lqw = Wrappers.lambdaQuery();
        if (StringUtils.isNotBlank(outwardTraining.getName())){
            lqw.like(OutwardTraining::getName ,outwardTraining.getName());
        }
        if (StringUtils.isNotBlank(outwardTraining.getJobNumber())){
            lqw.eq(OutwardTraining::getJobNumber ,outwardTraining.getJobNumber());
        }
        if (StringUtils.isNotBlank(outwardTraining.getPersonnelId())){
            lqw.eq(OutwardTraining::getPersonnelId ,outwardTraining.getPersonnelId());
        }
        if (StringUtils.isNotBlank(outwardTraining.getOfficeName())){
            lqw.like(OutwardTraining::getOfficeName ,outwardTraining.getOfficeName());
        }
        if (outwardTraining.getOfficeId() != null){
            lqw.eq(OutwardTraining::getOfficeId ,outwardTraining.getOfficeId());
        }
        if (StringUtils.isNotBlank(outwardTraining.getPostType())){
            lqw.eq(OutwardTraining::getPostType ,outwardTraining.getPostType());
        }
        if (StringUtils.isNotBlank(outwardTraining.getPostLevel())){
            lqw.eq(OutwardTraining::getPostLevel ,outwardTraining.getPostLevel());
        }
        if (StringUtils.isNotBlank(outwardTraining.getPositionalName())){
            lqw.like(OutwardTraining::getPositionalName ,outwardTraining.getPositionalName());
        }
        if (StringUtils.isNotBlank(outwardTraining.getPostName())){
            lqw.like(OutwardTraining::getPostName ,outwardTraining.getPostName());
        }
        if (StringUtils.isNotBlank(outwardTraining.getTrainingType())){
            lqw.eq(OutwardTraining::getTrainingType ,outwardTraining.getTrainingType());
        }
        if (StringUtils.isNotBlank(outwardTraining.getOutPlace())){
            lqw.eq(OutwardTraining::getOutPlace ,outwardTraining.getOutPlace());
        }
        if (StringUtils.isNotBlank(outwardTraining.getUnit())){
            lqw.eq(OutwardTraining::getUnit ,outwardTraining.getUnit());
        }
        if (StringUtils.isNotBlank(outwardTraining.getFrontOutTime())){
            lqw.eq(OutwardTraining::getFrontOutTime ,outwardTraining.getFrontOutTime());
        }
        if (StringUtils.isNotBlank(outwardTraining.getAfterOutTime())){
            lqw.eq(OutwardTraining::getAfterOutTime ,outwardTraining.getAfterOutTime());
        }
        if (StringUtils.isNotBlank(outwardTraining.getFrontReturnTime())){
            lqw.eq(OutwardTraining::getFrontReturnTime ,outwardTraining.getFrontReturnTime());
        }
        if (StringUtils.isNotBlank(outwardTraining.getAfterReturnTime())){
            lqw.eq(OutwardTraining::getAfterReturnTime ,outwardTraining.getAfterReturnTime());
        }
        if (StringUtils.isNotBlank(outwardTraining.getFundsSource())){
            lqw.eq(OutwardTraining::getFundsSource ,outwardTraining.getFundsSource());
        }
        if (StringUtils.isNotBlank(outwardTraining.getStatus())){
            lqw.eq(OutwardTraining::getStatus ,outwardTraining.getStatus());
        }
        return this.list(lqw);
    }
}
